package days2.easy.title27;

/**
 * @Author fengzihao
 * @Date 2024-04-16 14:12
 */
class Solution {
    public static int removeElement(int[] nums, int val) {
        int count = 0;// 用来记录已经删除了几个元素
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == val) {
                count++;
            } else {
                nums[i - count] = nums[i];
            }
        }
        return nums.length - count;
    }
}